package com.open.capacity.finance.controller;


import com.open.capacity.common.FileService;
import com.open.capacity.commons.Result;
import com.open.capacity.utils.file.FileUploadUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 系统升级
 *
 * @author
 * @email
 * @date 2020-08-07 09:20:08
 */
@Slf4j
@RestController
@RequestMapping("upgrades")
public class UpgradeController {

    @Value("${file.uploadpath:/usr/local/files/upload}")
    private String fileuploadPath;

    @Autowired
    private Environment env;

    @Autowired
    private FileService fileService;

    /**
     * 上传升级包
     */
    @RequestMapping("/upload")
    public Result upload(@RequestParam("file") MultipartFile file) throws IOException {
        // 上传并返回新文件名称
        String fileName = FileUploadUtils.upload3("D:\\tonghui\\finance", file);

        return Result.succeed(fileName, "上传成功");
    }

}
